﻿using UnityEngine;
using System.Collections;
using Dict.DataModel;

namespace Dict.Blo
{
    public class TableItemShopPriceBlo
    {
        public static TableItemShopPrice GetShopPrice(string productId, int count)
        {
            var list = Dict.DictDataManager.Instance.tableItemShopPriceDao.GetByOneIndex(productId);
            char[] sp = { '-' };
            for (int i = 0; i < list.Count; ++i)
            {
                string[] cs = list[i].count.Split(sp, System.StringSplitOptions.RemoveEmptyEntries);
                if (cs.Length == 1)
                {
                    if (cs[0] == count.ToString())
                    {
                        return list[i];
                    }
                }
                else if (cs.Length == 2)
                {
                    if (int.Parse(cs[0]) <= count && int.Parse(cs[1]) >= count)
                    {
                        return list[i];
                    }
                }
            }
            return null;
        }
    }
}